home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-19 | 11.6 KB | 302 lines | [TEXT/EDIT] |
- ( Reader application only ) forget task : task ;
-
- ( ************************* )
- ( **** W A R N I N G **** )
- ( ************************* )
- ( This file seals off the input routines of Pocket Forth )
- ( creating a stand alone application. The process is NOT )
- ( reversable! The copy of Pocket Forth this is loaded into )
- ( will no longer be usable as Pocket Forth. Be sure you )
- ( understand what you are doing before modifying this )
- ( program. Read it entirely. You have been warned. )
-
- ( Hit any key to continue. Quit from menu to abort. )
-
- key drop ( last chance )
- 0 28 +md ! ( shut off screen echo )
- 3000 grow
-
- : !FONT ( n -- ) >r ,$ A887 ; ( _TextFont )
- : !FSIZE ( n -- ) >r ,$ A88A ; ( _TextSize )
- : !FACE ( face -- ) >r ,$ A888 ; ( _TextFace )
- : SFONT ( -- ) 0 !font 12 !fsize ; ( 12 point Chicago )
- : CLS ( -- ) 4 +md a>r ,$ A8A3 20 20 !pen ; ( CLear Screen )
-
- : EVEN ( n -- n' ) dup 2 mod + ; ( round n up to an even number )
- : ," ( -- ) ( compile a quoted string from input stream )
- 34 word here c@ 1+ even allot ; IMMEDIATE
-
- : WINDOW ( -- window.pointer ) 0 +md 2@ ;
-
- ( menu support )
- : FMENUH ( -- dhandle ) 34 +md 2@ ; ( File menu handle )
- create "OPEN" ," Open" ( string data )
- create "CLOSE" ," Close" ( string data )
-
- : OIHANDLER ( -- addr ) ( the Open/Close item handler variable )
- 18 +md @ @ ; ( get pointer to File menu from menu list )
-
- : WHIDE ( -- ) window 2>r ,$ A916 ; ( _HideWindow )
- : WSHOW ( -- ) window 2>r ,$ A915 ; ( _ShowWindow )
-
- ( polygon handle storage )
- 2variable APOLY ( aft button dpoly handle )
- 2variable FPOLY ( fore button poly handle )
-
- : ?PHIT ( h v poly -- flag ) ( true if h,v is in polyBBox )
- 0 >r 2@ dl@ 2 0 d+ 2swap 2>r 2>r ,$ A8AD r> ; ( _PtInRect )
-
- ( create polygons )
- : *POLY ( addr -- ) 0 0 2>r ,$ A8CB 2r> rot 2! ; ( _OpenPoly )
- : *APOLY ( -- ) apoly *poly
- 5 225 !pen 20 210 -to 50 210 -to
- 50 240 -to 20 240 -to 5 225 -to ,$ A8CC ; ( _ClosePgon )
- : *FPOLY ( -- ) fpoly *poly
- 440 225 !pen 425 210 -to 390 210 -to
- 390 240 -to 425 240 -to 440 225 -to ,$ A8CC ; ( _ClosePgon )
-
- ( print polygon )
- : .POLY ( addr -- ) 2@ 2>r ,$ A8C6 ; ( _FramePoly )
- : .AARROW ( -- ) 015 230 !pen ." Back" apoly .poly ;
- : .FARROW ( -- ) 396 230 !pen ." Next" fpoly .poly ;
- : .ARROWS ( -- ) .aarrow .farrow ;
-
- ( print PICT resources from this file )
- : GETPICT ( id -- dhandle ) 0 0 2>r >r ,$ A9BC 2r> ; ( _GetPict )
- : DPICT ( rect id -- ) GetPict ( -- pictures.handle )
- 2dup 2>r rot a>r ,$ A8F6 ; ( _DrawPicture )
-
- ( rect words )
- : RECT ( compile: -- ) ( run: -- addr ) variable 6 allot ;
- : !RECT ( t l b r rect -- ) >r swap r 4 + 2! swap r> 2! ;
- : @RECT ( rect -- t l b r ) dup 2@ swap rot 4 + 2@ swap ;
- : ROFFSET ( h v rect -- ) a>r 2>r ,$ A8A8 ; ( _OffsetRect )
- : RINSET ( h v rect -- ) a>r 2>r ,$ A8A9 ; ( _InsetRect )
- : ?IN ( h v rect -- flag ) ( true if h,v is in rect at addr )
- 0 >r rot rot 2>r a>r ,$ A8AD r> ; ( _PtInRect )
- : ?EMPTY ( rect -- flag ) 0 >r a>r ,$ A8AE r> ; ( _EmptyRect )
- : RERASE ( rect -- ) a>r ,$ A8A3 ; ( _EraseRect )
-
- ( rects for pictures )
- rect PRECT 15 48 212 405 prect !rect ( title picture rect )
- rect SRECT 192 222 221 370 srect !rect ( signature rect )
-
- : SCR ( -- ) @pen swap drop 16 + 50 swap !pen ; ( special cr )
-
- ( P1 - P? are page drawing routines. They have no stack effect.)
- : P1 cls prect 4000 dpict
- 23 30 !pen ." NEW!" .farrow ;
-
- : P2 cls scr
- ." Its FAST, its FUN and its FREE!" scr scr
- ." Pocket Forth, release 5 is an ideal language" scr
- ." for experimenting with the Macintosh toolbox." cr scr
- ." For information, etc., send electronic mail to me" scr
- ." on CompuServe at [70566,1474]," scr
- ." Bitnet at “heilman@pc” or" scr
- ." U.S. mail to 85066-8345." scr
- ." I answer all mail and your input is welcome."
- srect 4001 dpict ( draw signature picture )
- .arrows ;
-
- : P3 cls scr
- ." Pocket Forth is a small compiling interpreter that" scr
- ." comes in application and DA versions." cr scr
- ." The code produced by Pocket Forth is both compact" scr
- ." and fast. Since Pocket Forth is a Forth language" scr
- ." system that produces true machine code, you have" scr
- ." complete control over (and responsibility for)" scr
- ." your program." cr scr
- ." The current release is System 7 friendly and will" scr
- ." run on any Macintosh/System combination. As with" scr
- ." all earlier releases, Pocket Forth is free."
- .arrows ;
-
- : P4 cls scr
- ." Get started and check out Pocket Forth's speed:" cr scr
- ." 1) Place a copy of Pocket Forth and the text file" scr
- ." called Sieve on a startup disk, not in any folder." scr
- ." 2) Double click on Pocket Forth's icon." scr
- ." 3) When the window says “ok” type:" scr
- ." --> sieve" scr
- ." with a 'return' at the end." scr
- ." 4) Watch the words scroll by, " 2 8 + !face ( outline italic )
- ." hold on!" 0 !face
- .arrows ;
-
- : P5 cls scr
- ." Pocket Forth release 5 contains:" scr
- ." • PocketForth0.5, the application" scr
- ." • PocketDA, a Font/DA Mover file" scr
- ." containing: PocketForth1.5, a System 7 DA" scr
- ." • The Pocket Forth Manual (an MS Word file)" scr
- ." • The Glossary of Pocket Forth words (an MS Word file)" scr
- ." • Complete source code and What's New?" cr scr
- ." Example Text Files:" scr
- ." • Sieve: The Sieve of Erastothanes benchmark" scr
- ." • Reader: Create this stand alone application" scr
- ." • Extras: Files, grafics, math, text editing and more…"
- .arrows ;
-
- : P6 cls scr
- ." Major changes since release 4:" cr scr
- ." • Multitasking and background operation." scr
- ." • High level events can be accepted." scr
- ." • All code is 32 bit clean." scr
- ." • Improved menus include Open command." scr
- ." • The manual has been updated." scr
- ." • Balloon help for System 7 users." scr
- ." • Color icons and pictures are included." scr
- .arrows ;
-
- : P7 cls cr scr
- ." Print and read the Manual and the Glossary." cr scr
- ." The Manual is a 23 page MS Word document" scr
- ." formatted for a laser printer." cr scr
- ." It is suitable for use as a reference to Pocket Forth" scr
- ." for old hats" 2 !face ." and" 0 !face ( italic )
- ." as a supplement to Brodie's" scr 4 !face ( underline )
- ." Starting FORTH" 0 !face ." for new Forthers."
- .arrows ;
-
- : P8 cls cr scr
- ." The Glossary is an 11 page MS Word document." cr scr
- ." The Glossary is a complete list of all of the words" scr
- ." in the Pocket Forth dictionary. Stack effects," scr
- ." pronounciation and common usage are shown."
- .arrows ;
-
- : P9 cls scr
- ." Source code, printed documentation, all of the" scr
- ." files, the Bezier DA kit and other examples are" scr
- ." available from the author." cr scr
- ." The Pocket Forth source is over 100K of MDS" scr
- ." assembly code. Instructions are included." cr scr
- ." The Bezier kit includes Bezier's source code," scr
- ." additional resources, and assembly instructions," scr
- ." as well as the completed DA and manual." cr scr
- ." Contact the author for any of these items."
- .aarrow ;
-
- variable PWHICH 0 pwhich ! ( which page to be drawn )
- create PLIST ( ordered list of routines or "pages" )
- ' p1 , ' p2 , ' p3 , ' p4 ,
- ' p5 , ' p6 , ' p7 , ' p8 , ' p9 ,
-
- ( menu, button and event handlers )
- : DOCLOSE ( -- ) ( the Close handler for the File menu )
- whide ( hide the window )
- fmenuh 2>r 1 >r "open" a>r ,$ A947 ( _SetItem )
- [ ' null literal here 2 - ] ( leave address for a forward reference )
- oihandler ! ;
-
- : DOOPEN ( -- ) ( the Open handler for the File menu )
- wshow ( hide the window )
- fmenuh 2>r 1 >r "close" a>r ,$ A947 ( _SetItem )
- [ ' doclose literal ] oihandler ! ;
- ' doopen swap ! ( resolve forward reference )
-
- : DOUP pwhich @ 2* plist + @ execute ; ( draw the pwhichth page )
- : DOAFT pwhich @ 1 - 0 max pwhich ! doup ; ( decrement pwhich )
- : DOFOR pwhich @ 1+ 8 min pwhich ! doup ; ( increment pwhich )
- : DOBUTT ( -- ) ( button handler )
- @mouse apoly ?phit IF apoly 2@ 2>r ,$ A8C9 doaft ELSE
- @mouse fpoly ?phit IF fpoly 2@ 2>r ,$ A8C9 dofor
- THEN THEN ;
-
- ( create and destroy pictures )
- : PICTURE ( rect -- dhandle ) ( open a picture )
- 0 0 2>r a>r ,$ A8F3 2r> ; ( _OpenPicture )
- : PCLOSE ,$ A8F4 ; macro ( _ClosePicture )
- : PKILL ( addr -- ) 2@ 2>r ,$ A8F5 ; ( _KillPicture at addr )
- : PDRAW ( rect dhandle -- ) ( draw a picture in rect )
- 2>r a>r ,$ A8F6 ; ( _DrawPicture )
-
- rect BRECT ( the bird's rect )
- rect OBRECT ( old brect )
- 2variable B1PICT ( hold b1's pict handle )
- 2variable B2PICT ( hold b2's pict handle )
- 2variable B3PICT ( hold b3's pict handle )
-
- ( draw the three bird positions )
- : .B1 2 0 !pen 6 0 -to 12 6 -to 18 0 -to 22 0 -to ;
- : .B2 0 6 !pen 24 6 -to ;
- : .B3 2 12 !pen 6 12 -to 12 6 -to 18 12 -to 22 12 -to ;
-
- : BNEW brect picture .b1 pclose b1pict 2!
- brect picture .b2 pclose b2pict 2!
- brect picture .b3 pclose b3pict 2! ;
- : BKILL b1pict pkill b2pict pkill b2pict pkill ;
-
- : B1 brect b1pict 2@ pdraw ;
- : B2 brect b2pict 2@ pdraw ;
- : B3 brect b3pict 2@ pdraw ;
- create .BS ' b1 , ' b2 , ' b3 , ( bird draw array )
- variable BTHIS 0 bthis ! ( offset to the current routine )
-
- : XLATE 3 -1 brect roffset ; ( translate brect )
- : INSET 1 1 brect rinset ; ( shrink brect )
-
- : ANIMATE ( -- ) ( draw the current bird, etc. )
- brect ?empty IF ( if the bird has shrunk to oblivion ... )
- 48 291 60 309 brect !rect THEN ( ... restore its origonal size )
- obrect rerase ( erase the old bird )
- brect @rect obrect !rect ( set the old bird to the current bird )
- 0 -1 obrect rinset ( expand the old birds rect )
- bthis @ ( get the current bird offset )
- dup .bs + @ execute ( execute the address of the draw bird routine )
- 4 < IF ( if its bird 1 or 2 )
- 2 bthis +! xlate ( increment bird offset and move the bird's rect )
- ELSE ( its bird 3 )
- 0 bthis ! xlate inset ( set bird 1, move and shrink bird's rect )
- 2 >r ,$ A889 ( SrcXor _TextMode )
- 23 30 !pen ." NEW! IMPROVED!" ( flip the title )
- THEN ;
-
- variable TLAST 0 tlast ! ( timer )
- 10 constant DELAY
- : TICKS ( -- n ) 364 0 l@ ;
- : ?TIME ( -- flags ) ( true if 1/delay seconds has elapsed )
- ticks tlast @ - abs delay > ;
- : DOIDLE
- pwhich @ 0= IF ( if its the title page )
- ?time IF ticks tlast ! animate
- THEN THEN ;
-
- : DOKEYS ( keycode -- )
- dup 49 = IF 0 pwhich ! doup THEN ( if it's 1 )
- dup 50 = IF doaft THEN ( if it's 2 )
- dup 51 = IF dofor THEN ( if it's 3 )
- dup 52 = IF 7 pwhich ! doup THEN ( if it's 4 )
- 0 -20 !pen drop ;
-
- : STOP bkill ,$ A9F4 ; ( _ExitToShell )
- : START *apoly *fpoly sfont
- 0 0 14 28 brect !rect bnew
- 0 0 0 0 brect !rect
- 0 0 0 0 obrect !rect
- begin key dokeys again ; ( event loop appl. only )
-
- 450 250 8 +md 2! ( set window size )
-
- ( set event/message handlers )
- ' doup 14 +md ! ( set update handler )
- ' dobutt 16 +md ! ( set button handler )
- ' doidle 20 +md ! ( set idle handler )
- ' start 26 +md ! ( set open handler )
- ' doclose 22 +md ! ( set close handler )
-
- ( set menu handlers )
- ' beep 18 +md @ ( get pointer to menu list )
- 2+ @ ( get pointer to Edit menu from menu list )
- 8 + ! ( set paste handler to beep )
- ' doclose oihandler ! ( set Open/Close menu handler )
- ' stop oihandler 4 + ! ( set quit handler )
-
- save : bye ,$ A9F4 ; bye ( save and quit )
-
- ( The ReadMe application also has been doctored with ResEdit )
- ( to smooth it out. The About DITL, Edit MENU, File MENU, )
- ( WIND, ICN#, and SIZE resources need to be changed. The )
- ( PICTs need to be added. )
-